home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Programming / Amos / AMOSList-1297 / AMOSLIST / 000013_amos-request@svcs1.digex.net_Tue Dec 2 16:45:02 1997.msg < prev    next >
Text File  |  1998-06-24  |  4KB  |  114 lines

  1. Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224])
  2.     by mail2.access.digex.net (8.8.5/8.8.5) with ESMTP id QAA08330
  3.     for <mcox@access.digex.net>; Tue, 2 Dec 1997 16:44:54 -0500 (EST)
  4. Received: (from daemon@localhost)
  5.     by svcs1.digex.net (8.8.5/8.8.5) id NAA13782
  6.     for amos-out; Tue, 2 Dec 1997 13:07:25 -0500 (EST)
  7. Received: from mail3.access.digex.net (mail3.access.digex.net [205.197.247.4])
  8.     by svcs1.digex.net (8.8.5/8.8.5) with ESMTP id NAA13777
  9.     for <amos-list@svcs1.digex.net>; Tue, 2 Dec 1997 13:07:25 -0500 (EST)
  10. Received: from mailhost.sosbbs.com (sosbbs.com [204.186.168.100])
  11.     by mail3.access.digex.net (8.8.5/8.8.5) with SMTP id NAA10919
  12.     for <amos-list@access.digex.net>; Tue, 2 Dec 1997 13:07:22 -0500 (EST)
  13. Received: from gbenjam (204.186.168.61) by mailhost.sosbbs.com
  14.  (EMWAC SMTPRS 0.81) with SMTP id <B0000150135@mailhost.sosbbs.com>;
  15.  Tue, 02 Dec 1997 13:06:16 -0500
  16. Message-ID: <B0000150135@mailhost.sosbbs.com>
  17. From: "Garfield Benjamin" <gbenjam@sosbbs.com>
  18. To: "AMOS MAILING LIST" <amos-list@access.digex.net>
  19. Subject: Re: Fast collisions
  20. Date: Tue, 2 Dec 1997 13:12:23 -0500
  21. X-MSMail-Priority: Normal
  22. X-Priority: 3
  23. X-Mailer: Microsoft Internet Mail 4.70.1155
  24. MIME-Version: 1.0
  25. Content-Type: text/plain; charset=ISO-8859-1
  26. Content-Transfer-Encoding: 7bit
  27. Status: O
  28. X-Status: 
  29.  
  30. > I seem to be stuck on a problem of detecting bob collisions.  My 
  31. > problems is that I need to test for so many.  I have a total of 12 
  32. > (or slightly more)  objects all of which must look out for eachother. 
  33. > Putting the collision detection routine in a loop is far too slow.  
  34. > Basically I have to call the collision detection procedure 100+ times 
  35. > per frame.  Is there an ultra fast way to do this?  My game is down 
  36. > to about 2 fps.  :(   Is there any way to do it without getting a 
  37. > special extension? 
  38.  
  39.    What sort of design are you using?
  40.    I normally rely on an optimized program-design to achieve the speed
  41.    in my projects, so...
  42.  
  43.    First, you need to set up your procedure _FINDHITNUM as well as
  44.    declare the global for it...
  45.  
  46.    Procedure _FINDHITNUM[FIRST, LAST]
  47.       HITFLAG=False : Rem  ...reset collision-flag
  48.       Rem  Run through the Col-list to see which Bob was Hit
  49.          For CHECKIT=FIRST To LAST
  50.             If Col(CHECKIT)
  51.                HITFLAG=CHECKIT : Rem  ...set flag to ID of object hit
  52.                CHECKIT=LAST : Rem ...my way to exit a loop
  53.             End If
  54.          Next CHECKIT
  55.    End Proc
  56.   
  57.    Global HITFLAG
  58.  
  59.    You have 12 objects which need to collide with any of the other 11,
  60.    so using Bob Col() you can "quickly" see if an object is colliding
  61.    with any of the others...
  62.  
  63.    This can be processed as follows:
  64.  
  65. For OBJECTNUM=0 to 11
  66.    Rem  Is this the first object?
  67.    If OBJECTNUM=0
  68.       Rem  yes, so need to check only against all "higher" objects...
  69.       If Bob Col(0, 1 To 11 )
  70.          _FINDHITNUM[1, 11]
  71.       End If
  72.  
  73.    Else
  74.       Rem  Is this the last object?
  75.       If OBJECTNUM=11
  76.          Rem  yes, so need to check only "lower" objects...
  77.          If Bob Col(11, 0 to 10)
  78.             _FINDHITNUM[0, 10]
  79.          End If
  80.       
  81.       Else
  82.          Rem  ObjectToCheck is between lowest and highest, so we 
  83.          Rem  need to perform two checks...
  84.          Rem  One for the objects lower than OBJECTNUM...
  85.          If Bob Col(OBJECTNUM, 0 To OBJECTNUM-1)
  86.             _FINDHITNUM[0, OBJECTNUM-1]   
  87.          Else
  88.             Rem and a second for objects higher than OBJECTNUM...
  89.             If Bob Col(OBJECTNUM, OBJECTNUM+1, 11)
  90.                _FINDHITNUM[OBJECTNUM+1, 11]
  91.             End If
  92.          End If
  93.        End If
  94.    End If
  95.   
  96.    Rem  This object has been checked, so we analyze the result...
  97.    If HITFLAG
  98.       Rem  If here, OBJECTNUM and HITFLAG objects have collided
  99.       Rem  so, do your processing...   
  100.    End If
  101. Next OBJECTNUM
  102.     
  103. This is a reasonably optimized design and AMOS should be able to
  104. sort out the collisions reasonably fast... :)
  105.  
  106. Let me know how you make out!!
  107.  
  108.  
  109.       Take  care,   
  110.       GARFIELD
  111.       _________________________
  112.       Current projects...
  113.       SideShooter(AMOS): 85% Complete
  114.       Website(http://www.sosbbs.com/~gbenjam): 20% Complete